{% extends 'base.html' %}
{% load static %}
{% block content %}
  <h1>Announcements</h1>
  {% for announcement in announcements %}
    <div class="card mb-3">
      <div class="card-body">
        <h2 class="card-title"><a href={% url "announcement_detail" announcement.pk %}>{{ announcement.title }}</a></h2>
        <h5 class="card-title">Category: {{ announcement.get_category_display }}</h5>
        <p class="embedly-card">{{ announcement.text|safe }}</p>
        <p class="card-text">
          <small class="text-muted">Created by {{ announcement.user.username }} at {{ announcement.created|date:'Y-m-d H:i' }}</small>
        </p>
        {% if request.user == announcement.user %}
        <a href="{% url 'announcement_update' announcement.pk %}" class="btn btn-warning">Edit</a>
        <a href="{% url 'announcement_delete' announcement.pk %}" class="btn btn-danger">Delete</a>
        {% endif %}
      </div>
    </div>
  {% empty %}
    <p>No announcements yet.</p>
  {% endfor %}
{% endblock %}
